package com.example.vuedemo.utils;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class R {
    private Integer code;
    private Boolean status;
    private String message;
    Map<String,Object> data = new HashMap<>();

    public R data(String key,Object value){
        this.data.put(key,value);
        return this;
    }

    public static R ok(){
        R r = new R();
        r.setCode(20000);
        r.setStatus(true);
        r.setMessage("成功");
        return r;
    }

    public static R error(){
        R r = new R();
        r.setCode(20001);
        r.setStatus(false);
        r.setMessage("失败");
        return r;
    }
}
